var Fei = {};

/**
 * 设置select 下拉框option选项
 * @param eleName select标签 id
 * @param url 服务地址
 */
Fei.initOption = function (eleName, url) {
    $.ajax({
        type: 'POST',
        url: Feng.ctxPath + url,
        dataType: 'json',
        success: function (data) {
            $.each(data, function (n, item) {
                $("#" + eleName).append("<option value=" + item.id + ">" + item.value + "</option>");
            });
        }
    });
};

Fei.initCheck = function (eleName, url) {
    $.ajax({
        type: 'POST',
        url: Feng.ctxPath + url,
        dataType: 'json',
        success: function (data) {
            $.each(data, function (n, item) {
                $("#" + eleName).append('<input type="checkbox" name="ids" value="' + item.id + '"/>' + item.name + '&nbsp;');
            });
        }
    });
};

Fei.collectCheckBox = function (name) {
    var ids = [];
    $('input[name=ids]:checked').each(function (index, item) {
        ids.push(item.value);
    });
    return ids;
};

Fei.submitJson = function (url, data) {
    $.ajax({
        type: 'POST',
        url: Feng.ctxPath + url,
        dataType: 'json',
        data: data,
        success: function (data) {
            Feng.success("操作成功!");
        }
    });
};